package com.opengroupe.entities;

// Generated 31 juil. 2012 15:46:15 by Hibernate Tools 3.4.0.CR1

import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Question generated by hbm2java
 */
@Entity
@Table(name = "question", catalog = "qrh")
@NamedQueries(value = {
	@NamedQuery(name="findByCategorie", query="SELECT q FROM Question q WHERE categorie= ?1")
})
public class Question implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 74439286227161718L;
	private Integer idQuestion;
	private Categorie categorie;
	private String contenuQuestion;
	private Set<CandidatReponseQuestion> candidatReponseQuestions = new HashSet<CandidatReponseQuestion>(
			0);
	private Set<Reponse> reponsesEventuelles = new HashSet<Reponse>(0);
	private Set<Reponse> reponsesCorrectes = new HashSet<Reponse>(0);

	public Question() {
	}

	public Question(Categorie categorie) {
		this.categorie = categorie;
	}

	public Question(Categorie categorie, String contenuQuestion,
			Set<CandidatReponseQuestion> candidatReponseQuestions,
			Set<Reponse> reponsesEventuelles, Set<Reponse> reponsesCorrectes) {
		this.categorie = categorie;
		this.contenuQuestion = contenuQuestion;
		this.candidatReponseQuestions = candidatReponseQuestions;
		this.reponsesEventuelles = reponsesEventuelles;
		this.reponsesCorrectes = reponsesCorrectes;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "idQuestion", unique = true, nullable = false)
	public Integer getIdQuestion() {
		return this.idQuestion;
	}

	public void setIdQuestion(Integer idQuestion) {
		this.idQuestion = idQuestion;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "idCategorie", nullable = false)
	public Categorie getCategorie() {
		return this.categorie;
	}

	public void setCategorie(Categorie categorie) {
		this.categorie = categorie;
	}

	@Column(name = "contenuQuestion", length = 65535)
	public String getContenuQuestion() {
		return this.contenuQuestion;
	}

	public void setContenuQuestion(String contenuQuestion) {
		this.contenuQuestion = contenuQuestion;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "question")
	public Set<CandidatReponseQuestion> getCandidatreponsequestions() {
		return this.candidatReponseQuestions;
	}

	public void setCandidatreponsequestions(
			Set<CandidatReponseQuestion> candidatReponseQuestions) {
		this.candidatReponseQuestions = candidatReponseQuestions;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "reponseeventuelle", catalog = "qrh", joinColumns = { @JoinColumn(name = "idQuestion", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "idReponse", nullable = false, updatable = false) })
	public Set<Reponse> getReponsesEventuelles() {
		return this.reponsesEventuelles;
	}

	public void setReponsesEventuelles(Set<Reponse> reponses) {
		this.reponsesEventuelles = reponses;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "reponsecorrecte", catalog = "qrh", joinColumns = { @JoinColumn(name = "idQuestion", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "idReponse", nullable = false, updatable = false) })
	public Set<Reponse> getReponsesCorrectes() {
		return this.reponsesCorrectes;
	}

	public void setReponsesCorrectes(Set<Reponse> reponses_1) {
		this.reponsesCorrectes = reponses_1;
	}

}
